//api文件夹用于存放对后台请求的代码
import service from "@/api/index.js";

const goodsApi = {
    insert(goods) {
        return service.post("/goods", goods);
    },
    delete(id) {
        return service.delete(`/goods/${id}`);
    },
    update(goods) {
        return service.put("/goods", goods);
    },
    //分页搜索
    selectByPage(condition, pageNum, pageSize) {
        condition.pageNum = pageNum;
        condition.pageSize = pageSize;
        return service.get("/goods/search", {
            params: condition
        });
    },
    //分页搜索--分类id既可以是父分类的id也可以是子分类的id
    selectByPage1(condition, pageNum, pageSize) {
        condition.pageNum = pageNum;
        condition.pageSize = pageSize;
        return service.get("/goods/search1", {
            params: condition
        });
    },
    //根据id查询
    selectById(id) {
        return service.get(`/goods/${id}`);
    },
}
export default goodsApi;//导出
